<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib prefix="sys" uri="/WEB-INF/tld/sys.tld" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>金融机构上报配置新增</title>
    <style type="text/css">
        .searchArea .fieldBox .label {
            width: 70px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<body class="iframeBody">
<div class="Wrapper">
    <form id="formSet1">
        <div class="fieldset1 tabel_col clearFix">
            <div class="fieldBox col_100_auto">
                <div class="label">创建人</div>
                <div class="field">
                    <input name="crtUsrNm" id="crtUsrNm" type="text" class="ui-textbox"
                           value="" validate="{required:true}" disabled = disabled>
                </div>
            </div>
            <div class="fieldBox col_100_auto">
                        <div class="label">创建时间</div>
                        <div class="field">
                            <input name="crtTm" id="crtTm" type="text" class="ui-textbox" value="" validate="{required:true}" disabled="disabled">
                        </div>
            </div>
            <div class="fieldBox col_100_auto">
                <div class="label">机构</div>
                <div class="field">
                    <input name="fundRasInsNm" id="fundRasInsNm" type="text">
                    <input name="funId" id="funId" type="hidden" value="${id }">
                </div>
            </div>
            <div class="fieldBox col_100_auto">
                <div class="label">上报类型</div>
                <div class="field">
                    <select name="upTyp" id="upTyp" data-value=" ">
                        <option value=" " checked >请选择</option>
                        <option value="2">风险上报</option>
                        <option value="1">非风险上报</option>
                    </select>
                </div>
            </div>
            <div class="fieldBox col_100_auto">
                <div class="label">机构放款时间</div>
                <div class="field">
                    <input ligerui="width: 120" name="payTmStart"
                           id="payTmStart" type="text" class="ui-datepicker" value=""> - <input
                        ligerui="width: 120" name="payTmEnd" id="payTmEnd"
                        type="text" class="ui-datepicker" value="">
                </div>
            </div>
            <div class="fieldBox col_100_auto">
                <div class="label">逾期天数</div>
                <div class="field">
                    <input name="overDueDaysStart" id="overDueDaysStart" type="text" class="ui-textbox" value="">-
                    <input name="overDueDaysEnd" id="overDueDaysEnd" type="text" class="ui-textbox" value="">
                </div>
            </div>
        </div>
        <div class="btnsBox">
            <span id="okBtn1" class="sq-button sq-button-round">确定</span>
            <span id="cancelBtn" class="sq-button sq-button-round">取消</span>
        </div>
    </form>
</div>


<script type="text/javascript">
    var _crtUsrId = '${crtUsrId}';
    var _crtTm = '${crtTm}';
    var _crtUsrNm = '${crtUsrNm}';
    $(function(){
        var formSet1 = $('#formSet1').ligerForm({
            validate : true
        });
        initData();
        SET_popupIframeHeight();
        btnIsShow();
        $("#fundRasInsNm").ligerComboBox({
            width: 200,
            slide: false,
            selectBoxWidth: 700,
            selectBoxHeight: 450,
            valueField: 'id',
            textField: 'fundRasInsNm',
            condition: {fields: [{name: 'fundRasInsNm', label: '金融机构', width: 90, type: 'text'}]},
            grid: getGridOptions(true),
            conditionSearchClick: function (e) {
                //debugger
                if (e.rules[0] && e.rules[0].value) {
                    e.grid.set('parms', {fundRasInsNm: e.rules[0].value});
                } else {
                    e.grid.set('parms', '');
                }
                e.grid.reload();

            },
            onSelected: function (id) {
                console.log('选择的是' + id);
                $('#funId').val(id);
            }
        });
    });
    function initData() {
        $("#crtTm").val(_crtTm);
        $("#crtUsrNm").val(_crtUsrNm);
    }
    function getGridOptions(checkbox) {
        var options = {
            columns: [
                {display: '金融机构ID', name: 'id', align: 'left', width: 120, minWidth: 60},
                {display: '金融机构名称', name: 'fundRasInsNm', minWidth: 120, width: 100},
            ], switchPageSizeApplyComboBox: false,
            url: '<%=path%>/rfbase/fribaseinfo/initList.do',
            method: 'get',
            pageSize: 10,
            root: 'rows',
            record: 'total',
            width: '100%',
            height: '100%'
            //checkbox: checkbox
        };
        return options;
    }

    var condition = {fields: [{name: 'fundRasInsNm', label: '商家名称:', width: 180, type: 'text'}]};
    var isSplNmModify = 1;
    function btnIsShow(){
    }
    $('#cancelBtn').click(function(){
        frameElement.dialog.close();
    });
    $('#okBtn1').click(function(){//确定
        check();
    });
    function check(){
        var form = liger.get("formSet1");
        /*if (!form.valid()) {
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
            return false; //验证不通过，不执行以下代码
        }*/
        var _funId = $.trim($("#funId").val());
        var data = form.getData();

        data["funId"] = _funId ;
        //发送异步请求校验
        var wait_dialog;
        $.ajax({
            type: 'get',
            dataType:'json',
            data:data,
            url: '<%=path%>/fgifuncfg/fgiFunCfg/add.do',
            beforeSend: function(){
                wait_dialog=top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
            },
            success:function(msg){
                var sign = 0;
                wait_dialog.close();
                if(msg.success == 1){
                    top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
                    frameElement.dialog.close();

                }else if(msg.success == 0){
                    top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                }
            }
        });
    }

    /**
     * @iframe_id iframe的id
     * @action post 地址
     * @title tab标签的显示名称
     * @params: Object
     *  - @postData 键值对json对象
     *  - @callback 回调方法
     */
    function Add_navTab_post(iframe_id, title, action, receive, postData) {
        var _form = $('<form id="myForm" method="post" target="'+iframe_id+'" action="'+action+'" style="height: 0; overflow: hidden;"></form>')
        var _keys = Object.keys(postData)
        _keys.forEach(function (key) {
            _form.append('<input type="hidden" name="'+key+'" value="'+postData[key]+'" />')
        })
        top.$('body').append(_form)
        Add_navTab(iframe_id, title, '/', receive);
        _form.submit()
        _form.remove()
    }

</script>



</body>
</html>
